﻿//-----------------------------------------------------------------------
// <copyright file="OtherUsersIntervalToTextConverter.cs" company="AFS">
// Copyright (c) AFS. All rights reserved.
//
//    This file is part of Chatbox.
//
//    Chatbox is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    any later version.
//
//    Chatbox is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Chatbox. If not, see http://www.gnu.org/copyleft/lesser.html
// </copyright>

namespace ChatBox.UI.ValueConverters
{
    using System;
    using System.Globalization;
    using System.Windows.Data;

    using DomainObjects.Settings;

    /// <summary>
    /// Class to convert a message interval to text
    /// </summary>
    public class OtherUsersIntervalToTextConverter : IValueConverter
    {
        #region IValueConverter Members

        /// <summary>
        /// Convert the value from the connection state enum to a coloured brush
        /// </summary>
        /// <param name="value">the value to convert</param>
        /// <param name="targetType">the target type</param>
        /// <param name="parameter">conversion params</param>
        /// <param name="culture">culture info</param>
        /// <returns>the converted value</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null || !(value is double))
            {
                return value;
            }

            double doubleValue = (double)value;
            return MessageIntervalToTextConverterHelper.MakeTextFromIntervalValue(
                doubleValue,
                ServerSettingsDataHelper.MinOtherUsersRefreshInterval,
                ServerSettingsDataHelper.MaxOtherUsersRefreshInterval);
        }

        /// <summary>
        /// Convert back -  not handled
        /// </summary>
        /// <param name="value">the value to convert</param>
        /// <param name="targetType">the target type</param>
        /// <param name="parameter">conversion params</param>
        /// <param name="culture">culture info</param>
        /// <returns>the converted value</returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
